﻿/*
 * Name:        SnkLabel
 * Description: UI part that acts as a Label
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

using Gyvate.Worldspawn;
using Gyvate.Util;

namespace Gyvate.GFX
{
    internal class SnkLabel : SnkPanel
    {
        protected Font m_font;
        protected Brush m_fgBrush;
        protected string m_string;

        /*
         * Constructor with Dimensions2D param
         */
        public SnkLabel(Game game, Dimensions2d dim, string text)
            : base(game, dim)
        {
            m_string = text;
        }

        /*
         * Constructor with 2x Vector2f params that will be turned into Dimensions2d
         */
        public SnkLabel(Game game, Vector2d pos, Vector2d size, string text)
            : base(game, pos, size)
        {
            m_string = text;
        }

        /*
         * Constructor with Dimensions2D param
         * Empty text string
         */
        public SnkLabel(Game game, Dimensions2d dim)
            : base(game, dim)
        {
            m_string = "";
        }

        /*
         * Constructor with 2x Vector2f params that will be turned into Dimensions2d
         * Empty text string
         */
        public SnkLabel(Game game, Vector2d pos, Vector2d size)
            : base(game, pos, size)
        {
            m_string = "";
        }
        
        /*
         * Changes text of the label
         */
        public void SetText(string text)
        {
            m_string = text;
        }

        /*
         * Applies default scheme settings
         */
        override internal void ApplyScheme(Dimensions2d dim)
        {
            base.ApplyScheme(dim);
            SetFGColour(Color.White);
            m_font = new Font("Times New Roman", 12.0f);
        }

        /*
         * Sets foreground colour
         */
        public void SetFGColour(Color colour)
        {
            m_fgBrush = new SolidBrush(colour);
        }

        /*
         * Sets font
         */
        public void SetFont(string font, float size)
        {
            m_font = new Font(font, size);
        }

        /*
         * Sets font
         */
        public void SetFont(Font fnt)
        {
            m_font = fnt;
        }

        /*
         * Draws to buffer
         */
        internal override void Draw()
        {
            if (!IsVisible())
                return;

            base.Draw();
            m_game.GetUIParent().DrawString(m_string, m_font, m_fgBrush, GetDimensions().pos.x, GetDimensions().pos.y);
        }


    }
}
